<!--
 * @Author: your name
 * @Date: 2021-07-18 16:01:48
 * @LastEditTime: 2021-08-02 00:12:18
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \blog-work\src\pages\post.vue
-->
<template>
    <div>
        <Layout>
            <!-- Page Header-->
            <header class="masthead" style="background-image: url('/img/post-bg.jpg')">
                <div class="container position-relative px-4 px-lg-5">
                    <div class="row gx-4 gx-lg-5 justify-content-center">
                        <div class="col-md-10 col-lg-8 col-xl-7">
                            <div class="post-heading">
                                <h1 v-html="mdToHtml($page.post.title)"></h1>
                                <h2 class="subheading">{{$page.post.tags.map(i=>i.title).join(',')}}</h2>
                                <span class="meta">
                                    Posted by
                                    <a href="#!">Start Bootstrap</a>
                                    {{$page.post.created_at}}
                                </span>
                            </div>
                        </div>
                    </div>
                </div>
            </header>
            <!-- Post Content-->
            <article class="mb-4">
                <div class="container px-4 px-lg-5">
                    <div class="row gx-4 gx-lg-5 justify-content-center">
                        <div class="col-md-10 col-lg-8 col-xl-7" v-html="mdToHtml($page.post.content)">

                        </div>
                    </div>
                </div>
            </article>
        </Layout>
    </div>
</template>
<page-query>

    query ($id:ID!) {
    post:strapiPosts(id:$id) {
    id
    title
    content
    tags {
    id
    title
    }
    created_at
    }
    }
</page-query>
<script>
    import MarkdowIt from 'markdown-it'
    const md = new MarkdowIt()
    export default {
        name: 'postPage',
        methods: {
            mdToHtml(md1) {
                return md.render(md1)
            }
        }
    }
</script>